package com.ki.erp.pl;

import com.ki.erp.entity.User;
import jakarta.annotation.Resource;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Component;

import static org.springframework.data.mongodb.core.query.Criteria.where;
import static org.springframework.data.mongodb.core.query.Query.query;

@Component
public class UserPlImpl {
    private @Resource MongoTemplate erpTemplate;

    public User getById(String id) {
        return erpTemplate.findById(id, User.class);
    }

    public User getByName(String name) {
        return erpTemplate.findOne(query(where("name").is(name)), User.class);
    }
}
